package com.oracle.interceptor;


import com.oracle.Service.impl.BookService;
import com.oracle.pojo.Book;
import com.oracle.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;

public class UserOrderInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //判断用户是否登录登陆了，才能进入提交订单和付款
        HttpSession session = request.getSession();
        User login = (User) session.getAttribute("userLogin");
        if (login==null){
            session.setAttribute("noUser", "没有登录用户");
            response.sendRedirect(request.getContextPath()+"/user/front/indexView");
            return false;
        }
        return true;
    }
}
